home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15729 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.1 KB  |  63 lines

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How do the functions in <time.h> work?
  5. Date: 21 Apr 1996 12:58:18 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4ldbda$t08@sparcserver.lrz-muenchen.de>
  9. References: <317653DA.5066@ix.netcom.com> <829950824snz@genesis.demon.co.uk> <317909EE.648E@ix.netcom.com>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. Jane Harper <jharper@ix.netcom.com> writes:
  13.  
  14. >Lawrence Kirby wrote:
  15. >> 
  16. >> We can't tell what you did unless you post some code. ctime() takes an
  17. >> argument which is a pointer to the time_t value you want to convert.
  18. >> Presumably you didn't pass it such a pointer.
  19.  
  20. >About the immediate question of my code, you are correct. However, I'm 
  21. >at least as interested in *how* the functions work.  What's time_t a 
  22. >typedef *for*?
  23.  
  24. A type that is capable of storing a date and time.
  25.  
  26. >DOes it have other uses?  The ctime() prototype mentions 
  27. >an argument "*timer" .. whazzat and what does *it* do?  What type is it?
  28.  
  29. If the prototype of ctime() is similar to
  30.  
  31.   char *ctime(const time_t *timer);
  32.  
  33. as it should be, then
  34.  
  35.    "ctime" is a function taking a pointer to time_t, that will not be
  36.    modified through that pointer by the function, and returning a pointer
  37.    to char.
  38.  
  39. >Perhaps my real problem lies in my inability to understand completely 
  40. >the code within the <time.h> file ..
  41.  
  42. The "code" inside a header file is limited to declarations and definitions
  43. in most cases. Standard C libraries are accompanied by a documentation,
  44. and the implementaion of that library should be documented in that
  45. documentation. Anyway, a short example might be helpful:
  46. ----------------------8<--------------8<---------------------------
  47. #include <time.h>
  48.  
  49. main()
  50. {
  51.    time_t now;
  52.  
  53.    time(&now);        /* Get the current time and date */
  54.    puts(ctime(&now)); /* Print a text representation thereof */
  55.    return 0;
  56. }
  57. ----------------------8<--------------8<---------------------------
  58.  
  59. Kurt
  60. --
  61. | Kurt Watzka                             Phone : +49-89-2180-6254
  62. | watzka@stat.uni-muenchen.de
  63.